<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer">
      <span class="todo-count"><strong>{{res}}</strong>剩余</span>
      <ul class="filters">
        <li>
          <a :class="{selected:type==='all'}"
             @click="highLight('all')"
             href="#/">全部</a>
        </li>
        <li>
          <a :class="{selected:type==='active'}"
             @click="highLight('active')"
             href="#/active">进行中</a>
        </li>
        <li>
          <a :class="{selected:type==='completed'}"
             @click="highLight('completed')"
             href="#/completed">已完成</a>
        </li>
      </ul>
      <button class="clear-completed"
              @click="delAll">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      required: true
    },
    type:{
      type:String,
      required:true
    }
  },
  computed: {
    res () {
      return this.list.filter(item => item.flag === false).length
    }
  },
  methods: {
    delAll () {
      this.$emit('delAll')
    },
    highLight (type){
      this.$emit('changeType',type)
    }
  }
}
</script>

<style scoped>
</style>